#include "MarsPrecompile.h"

#include "MarsCRC.h"

namespace Core
{

// CRC 32 polynomial.
#define CRC32_POLY 0x04c11db7

/** 
* Helper class for initializing the global GCRCTable
*/
class FCRCTableInit
{
public:
	/**
	* Constructor
	*/
	FCRCTableInit()
	{
		// Init CRC table.
		for ( uint32 iCRC = 0; iCRC < 256; iCRC++ )
		{
			for ( uint32 c=iCRC << 24, j = 8; j != 0; j-- )
			{
				g_CRCTable[iCRC] = c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1);
			}
		}
	}	
};

uint32 g_CRCTable[ 256 ];
static FCRCTableInit s_init;

} // end of namespace Core
